package com.bawei.module_live.ui.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_live.R
import com.bawei.module_live.data.LuckData

class LuckListAdapter(private val data: List<LuckData>) : RecyclerView.Adapter<LuckListAdapter.LuckViewHolder>() {

    class LuckViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val tvName: TextView = itemView.findViewById(R.id.tv_name)
        val tvMoney: TextView = itemView.findViewById(R.id.tv_money)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LuckViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_luck_user, parent, false)
        return LuckViewHolder(view)
    }

    override fun onBindViewHolder(holder: LuckViewHolder, position: Int) {
        val user = data[position]
        holder.tvName.text = user.name
        holder.tvMoney.text = "￥${user.money}"
    }

    override fun getItemCount(): Int = data.size
}